package com.bawei.park2211a.equipment

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.bawei.base.mvvm.BaseActivity
import com.bawei.park2211a.R
import com.bawei.park2211a.adapter.EquipmentAdapter
import com.bawei.park2211a.databinding.ActivityEquipmentBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/app/equipment/EquipmentActivity")
class EquipmentActivity : BaseActivity<ActivityEquipmentBinding,EquipmentViewModel>() {
    lateinit var equipmentAdapter: EquipmentAdapter
    override fun initView() {
        viewModel.equipment()
        equipmentAdapter = EquipmentAdapter()
        binding.equipmentRec.adapter=equipmentAdapter
        binding.equipmentRec.layoutManager=LinearLayoutManager(this)
    }

    override fun initData() {
        viewModel.equipmentSuccess.observe(this){
            equipmentAdapter.data.clear()
            equipmentAdapter.data.addAll(it)
            equipmentAdapter.notifyDataSetChanged()
        }
    }
}